<?php

namespace app\common\validate;

use think\Validate;

class BannerValidate extends Validate
{
    /**
     * 定义验证规则
     * 格式：'字段名'	=>	['规则1','规则2'...].
     *
     * @var array
     */
    protected $rule = [
        'id|编号' => 'require|number|gt:0',
        'tag|轮播标识' => 'require|min:2',
        'img_url|图片地址' => 'require|min:2',
        'redirect_type|重定向类型' => 'require|number|in:0,1,2,3,4',
        'redirect_id|重定向id' => 'number|gt:0',
        'redirect_link|重定向链接' => 'min:2',
        'remarks|备注' => 'min:2',
        'sort|排序' => 'require|number|gt:0',
        'page|页数' => 'require|number|gt:0',
        'limit|分页大小' => 'require|number|gt:5',
    ];

    /**
     * 定义错误信息
     * 格式：'字段名.规则名'	=>	'错误信息'.
     *
     * @var array
     */
    protected $message = [];
    protected $scene = [
        'getListPage' => ['page', 'limit'],
        'saveAdd' => ['tag', 'img_url', 'redirect_type', 'redirect_id', 'redirect_link', 'remarks', 'sort'],
        'saveEdit' => ['id'],
        'getRow' => ['id'],
    ];
}
